﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class UserControl_Xemthongtincanhan1 : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //string user = Request.QueryString["username"];
        //if (Session["User"] != null)
        //{

        //    string username = ((Users)Session["User"]).Username.ToString();


        //    Label1.Text = Application["user"].ToString();
        //    xuatHoso(username);
        //}
        //else
        //{
        //    xuatHoso(user);
        //}
        string username ;
        if (Request.QueryString["username"] == null)
        {
            //Xem profile cua user
            if (Session["User"] != null)
            {
                username = ((Users)Session["User"]).Username.ToString();

                Label1.Text = Application["user"].ToString();
                xuatHoso(username);
            }
            else
            {
                Response.Redirect("Login.aspx");
            }
        }
        else 
        { 
            username = Request.QueryString["username"];
            Label1.Text = Application["user"].ToString();
            xuatHoso(username);
        }
                      
    }

    void xuatHoso(String Username)
    {
        UsersBLL userBLL = new UsersBLL();
      
        Users admin = userBLL.GetIUsers.GetUserByUsername(Username);



        UserProfiles adminProfiles = userBLL.GetIUserProfiles.GetUserProfileOfUser(admin);
        try
        {
            this.txtTaikhoan.Text = adminProfiles.User.Username;
            txtEmail.Text = adminProfiles.User.Email;
            txtDantoc.Text = adminProfiles.People;
            txtSothich.Text = adminProfiles.Interests;
            txtNghenghiep.Text = adminProfiles.Jobs;
            txtThoigian.Text = adminProfiles.CreateTime.ToString();

            if (bool.Parse(adminProfiles.Gender.ToString()) == true)
            {
                checgtNa.Checked = true;
                checgtN.Visible = false;
                checgtNa.Enabled = false;
                checgtNa.Visible = true;
                checgtN.Enabled = false;
            }
            else
            {

                checgtN.Checked = true;
                checgtN.Visible = true;
                checgtNa.Enabled = false;
                checgtN.Enabled = false;
                checgtNa.Visible = false;
            }

        }
        catch
        {
            Response.Write("<script>alert('User khong hop le')</script>");
        }
    }
    protected void txttaikhoan_TextChanged(object sender, EventArgs e)
    {
        

  

       

        
                
                
    }
    void xuat_hosomoi()
    {
        txtThoigian.Text = "";
        txtEmail.Text = "";
        txtSothich.Text = "";
        txtTaikhoan.Text = "";
        txtDantoc.Text = "";
        txtNghenghiep.Text = "";
        checgtN.Visible = false;
        checgtNa.Visible = false;
        
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        
       
    }
}